{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Python wrapper of REFPROP\n",
    "\n",
    "Tutorial written by Ian Bell, NIST, 2018.  Want to contribute to it, or think this tutorial is missing an important topic?  Please make a note at https://github.com/usnistgov/REFPROP-wrappers/issues/new\n",
    "\n",
    "## Help\n",
    "\n",
    "If you have any problems with this wrapper, please open an issue at github: https://github.com/usnistgov/REFPROP-wrappers/issues/new\n",
    "\n",
    "## Installation\n",
    "\n",
    "The Python wrapper of REFPROP can be installed with\n",
    "\n",
    "```\n",
    "pip install ctREFPROP\n",
    "```\n",
    "More installation instructions are available at [REFPROP-wrappers](https://github.com/usnistgov/REFPROP-wrappers/tree/master/wrappers/python)\n",
    "\n",
    "The wrapper is auto-generated to keep up-to-date with the FORTRAN code.  It is written in pure python with no dependencies aside from the standard library of Python\n",
    "\n",
    "## Setup\n",
    "\n",
    "*Windows normal users*: The Python wrapper of NIST REFPROP needs to be informed where its files are installed.  If you use the default installation location, and you have installed REFPROP with the MSI installer that you obtained from NIST, the ``RPPREFIX`` environment variable has been set, pointing to your installation, and you should not need to do anything with regards to setup.\n",
    "\n",
    "*Superusers*: If, on the other hand, you have used the [REFPROP-cmake](https://github.com/usnistgov/REFPROP-cmake) build system to build REFPROP yourself (the recommended build system for custom builds), you will need to copy the ``FLUIDS`` and ``MIXTURES`` directories to the appropriate folder in which your .DLL/.so/.dylib is located.  The ``SETPATHdll`` function (see example below) informs REFPROP where it should be able to find the files that it needs."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "# This path is suitable for the developer's computer (the developer has multiple \n",
    "# copies of REFPROP installed on their computer), but the default configuration \n",
    "# with the REFPROP installer on windows should not require this step\n",
    "import os\n",
    "os.environ['RPPREFIX'] = r'C:/Program Files (x86)/REFPROP'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Import the main class from the Python library\n",
    "from ctREFPROP.ctREFPROP import REFPROPFunctionLibrary\n",
    "\n",
    "# Imports from the standard library\n",
    "import glob\n",
    "\n",
    "# Imports from conda-installable packages\n",
    "import pandas\n",
    "\n",
    "# Import numpy\n",
    "import numpy as np\n",
    "\n",
    "# Import matplotlib for plotting\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Use"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Now we instantiate the library, and use the environment variable to\n",
    "# explicitly state which path we want to use. It was decided to make\n",
    "# the path handling explicit (though more verbose), because explicit \n",
    "# is almost always better than implicit\n",
    "RP = REFPROPFunctionLibrary(os.environ['RPPREFIX'])\n",
    "\n",
    "# Now we tell REFPROP what the root directory is that it should use.  This root directory should contain, at least:\n",
    "# A) REFPRP64.DLL (or REFPROP.dll for 32-bit windows, or librefprop.so or librefprop.dylib, for linux or OSX respectively)\n",
    "# B) FLUIDS folder (case sensitive)\n",
    "# C) MIXTURES folder (case sensitive)\n",
    "RP.SETPATHdll(os.environ['RPPREFIX'])\n",
    "\n",
    "# Get the unit system we want to use (we will revisit this GETENUM function later)\n",
    "MOLAR_BASE_SI = RP.GETENUMdll(0, \"MOLAR BASE SI\").iEnum"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'10.0.0.02'"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# The version of REFPROP (if this gives ***** with REFPROP 10.0.0, please see us to get a patch)\n",
    "RP.RPVersion()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "373.1242958476953"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# The classical first example, calculating the boiling temperature of water\n",
    "# at one atmosphere (101325 Pa) in K\n",
    "p_Pa = 101325\n",
    "Q = 0.0\n",
    "r = RP.REFPROPdll(\"Water\",\"PQ\",\"T\",MOLAR_BASE_SI,0,0,p_Pa,Q,[1.0])\n",
    "r.Output[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "373.1242958476953"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# You may also pass an absolute path to the .FLD file if you would like, which \n",
    "# supercedes the path specified to SETPATHdll\n",
    "p_Pa = 101325\n",
    "Q = 0.0\n",
    "FLDpath = os.path.join(os.environ['RPPREFIX'],\"FLUIDS\",\"WATER.FLD\")\n",
    "r = RP.REFPROPdll(FLDpath,\"PQ\",\"T\",MOLAR_BASE_SI,0,0,p_Pa,Q,[1.0])\n",
    "r.Output[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "REFPROPdlloutput(z=array('d', [1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]), Output=array('d', [373.1242958476953, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0, -9999990.0]), hUnits='K', iUCode=1, x=array('d', [1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]), y=array('d', [1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]), x3=array('d', [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]), q=0.0, ierr=0, herr='')"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# In each call to REFPROP, a named collections.namedtuple is returned, let's see what \n",
    "# we got from the last call\n",
    "r"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# We can access fields by name\n",
    "r.ierr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "('K', 'K')"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Or by value (here, the units string, accessed by index and by attribute)\n",
    "r[2], r.hUnits"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "# You should always check the ierr code; ierr > 100 are fatal errors\n",
    "# See also http://refprop-docs.readthedocs.io/en/latest/DLL/high_level.html#f/_/ERRMSGdll\n",
    "assert r.ierr < 100"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Unit sytems\n",
    "\n",
    "REFPROP supports a variety of unit systems (see [the docs](http://refprop-docs.readthedocs.io/en/latest/DLL/high_level.html#f/_/REFPROPdll)).  Though your calculations should only ever be done in SI-derived units (and preferably in base SI units (Pa, J, kg, mol)), you can also use other unit systems in REFPROP.  See the docs for more information on the use of IP units.  You can retrieve the enumerated values for the unit system (used in the ``REFPROPdll`` function, and in other functions in the high-level API) from the ``GETENUMdll`` function.  All the examples here use \n",
    "the molar base SI unit system.\n",
    "\n",
    "You may also access the standard unit systems by attribute: ``RE.MOLAR_BASE_SI`` for instance"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "2\n",
      "20\n",
      "And by attribute:\n",
      "0\n",
      "20\n"
     ]
    }
   ],
   "source": [
    "for unit_string in 'DEFAULT','SI','MOLAR BASE SI':\n",
    "    print(RP.GETENUMdll(0, unit_string).iEnum)\n",
    "\n",
    "print('And by attribute:')\n",
    "print(RP.DEFAULT)\n",
    "print(RP.MOLAR_BASE_SI)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Inputs/Outputs"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array('d', [16917.95693422109, 88.67082187819227, -4990.492643521272, 8.3144598, 0.102032, 741.96879436991])"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# You can get multiple outputs from the REFPROP function, for instance here we get \n",
    "# the molar enthalpy, molar entropy, molar Gibbs energy, the gas constant, the \n",
    "# molar mass, and the speed of sound\n",
    "# \n",
    "# Additional properties are listed in the documentation\n",
    "#\n",
    "# N.B. The enthalpy, entropy, and Gibbs energies obtained are a function of the reference \n",
    "# state selected\n",
    "RP.REFPROPdll(\"R134A\",\"PQ\",\"H;S;G;R;M;W\",MOLAR_BASE_SI,0,0,101325,0,[1.0]+[0.0]*19).Output[0:6]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Retrieving Fluid Information"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Numerical outputs, stored in Output\n",
      "-----------------------------------\n",
      "TC [K]: 369.89 \n",
      "PC [MPa]: 4.2512 \n",
      "DC [mol/dm^3]: 5.0 \n",
      "TTRP [K]: 85.525 \n",
      "PTRP [MPa]: 1.72e-10 \n",
      "MM [g/mol]: 44.09562 \n",
      "ACF [-]: 0.1521 \n",
      "DIPOLE [debye]: 0.084 \n",
      "TNBP [K]: 231.036 \n",
      "REOS [(J/mol)/K]: 8.3144598 \n",
      "ODP [-]: -1.0 \n",
      "GWP [-]: 3.3 \n",
      "TMIN [K]: 85.525 \n",
      "TMAX [K]: 650.0 \n",
      "PMAX [MPa]: 1000.0 \n",
      "HEATCOMB [J/mol]: 2219170.0 \n",
      "HFRM [J/mol]: -104683.0 \n",
      "\n",
      "String Outputs, stored in hUnits\n",
      "--------------------------------\n",
      "ALTID: Not available\n",
      "CAS#: 74-98-6\n",
      "CHEMFORM: C3H8\n",
      "FULLCHEMFORM: CH3CH2CH3\n",
      "SYNONYM: R-290\n",
      "FAMILY: n-alkane\n",
      "HASH: 70c6aac0\n",
      "INCHI: 1S/C3H8/c1-3-2/h3H2,1-2H3\n",
      "INCHIKEY: ATUOYWHBWRKTHZ-UHFFFAOYSA-N\n",
      "LONGNAME: Propane\n",
      "SAFETY: A3\n",
      "NAME: Propane\n",
      "UNNUMBER: 1075, 1978\n",
      "DOI_EOS(1): 10.1021/je900217v\n",
      "WEB_EOS(1): \n",
      "REFSTATE: IIR\n",
      "FLDNAME: Propane.FLD\n",
      "FDIR(1): C:/Program Files (x86)/REFPROP/fluids/Propane.FLD\n"
     ]
    }
   ],
   "source": [
    "z = [1.0] + [0.0]*19\n",
    "MOLAR_SI = RP.GETENUMdll(0,\"MOLAR SI\").iEnum\n",
    "\n",
    "# Print out a range of properties for a well-known fluid\n",
    "f = 'Propane'\n",
    "print('Numerical outputs, stored in Output')\n",
    "print('-----------------------------------')\n",
    "for k in [\"TC\",\"PC\",\"DC\",\"TTRP\",\"PTRP\",\"MM\",\"ACF\",\n",
    "          \"DIPOLE\",\"TNBP\",\"REOS\",\"ODP\",\"GWP\",\"TMIN\",\n",
    "          \"TMAX\",\"PMAX\",\"HEATCOMB\",\"HFRM\"]:\n",
    "    r = RP.REFPROPdll(f,\"\",k,MOLAR_SI,0,0,0,0,z)\n",
    "    print(k + ' [' + r.hUnits+']:', r.Output[0], r.herr)\n",
    "\n",
    "print('\\nString Outputs, stored in hUnits')\n",
    "print('--------------------------------')\n",
    "for k in [\"ALTID\",\"CAS#\",\"CHEMFORM\",\"FULLCHEMFORM\",\"SYNONYM\",\n",
    "          \"FAMILY\",\"HASH\",\"INCHI\",\"INCHIKEY\",\"LONGNAME\",\n",
    "          \"SAFETY\",\"NAME\",\"UNNUMBER\",\"DOI_EOS(1)\" ,\n",
    "          \"WEB_EOS(1)\",\"REFSTATE\",\"FLDNAME\",\"FDIR(1)\"]:\n",
    "    r = RP.REFPROPdll(f,\"\",k,MOLAR_SI,0,0,0,0,z)\n",
    "    print(k + ':', r.hUnits)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>NAME</th>\n",
       "      <th>TC [K]</th>\n",
       "      <th>PC [MPa]</th>\n",
       "      <th>DC [mol/dm^3]</th>\n",
       "      <th>INCHIKEY</th>\n",
       "      <th>HASH</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>77</th>\n",
       "      <td>NEON</td>\n",
       "      <td>44.4000</td>\n",
       "      <td>2.66163</td>\n",
       "      <td>24.100000</td>\n",
       "      <td>GKAOGPIIYCISHV-UHFFFAOYSA-N</td>\n",
       "      <td>b912fce0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>145</th>\n",
       "      <td>WATER</td>\n",
       "      <td>647.0960</td>\n",
       "      <td>22.06400</td>\n",
       "      <td>17.873728</td>\n",
       "      <td>XLYOFNOQVPJJNP-UHFFFAOYSA-N</td>\n",
       "      <td>b43a7600</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>34</th>\n",
       "      <td>D2O</td>\n",
       "      <td>643.8470</td>\n",
       "      <td>21.66180</td>\n",
       "      <td>17.775550</td>\n",
       "      <td>XLYOFNOQVPJJNP-ZSJDYOACSA-N</td>\n",
       "      <td>3e131610</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>52</th>\n",
       "      <td>HELIUM</td>\n",
       "      <td>5.1953</td>\n",
       "      <td>0.22832</td>\n",
       "      <td>17.383700</td>\n",
       "      <td>SWQJXJOGLNCZEY-UHFFFAOYSA-N</td>\n",
       "      <td>3b8eed30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>D2</td>\n",
       "      <td>38.3400</td>\n",
       "      <td>1.67960</td>\n",
       "      <td>17.230000</td>\n",
       "      <td>UFHFLCQGNIYNRP-VVKOMZTBSA-N</td>\n",
       "      <td>639b18a0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       NAME    TC [K]  PC [MPa]  DC [mol/dm^3]                     INCHIKEY  \\\n",
       "77     NEON   44.4000   2.66163      24.100000  GKAOGPIIYCISHV-UHFFFAOYSA-N   \n",
       "145   WATER  647.0960  22.06400      17.873728  XLYOFNOQVPJJNP-UHFFFAOYSA-N   \n",
       "34      D2O  643.8470  21.66180      17.775550  XLYOFNOQVPJJNP-ZSJDYOACSA-N   \n",
       "52   HELIUM    5.1953   0.22832      17.383700  SWQJXJOGLNCZEY-UHFFFAOYSA-N   \n",
       "33       D2   38.3400   1.67960      17.230000  UFHFLCQGNIYNRP-VVKOMZTBSA-N   \n",
       "\n",
       "         HASH  \n",
       "77   b912fce0  \n",
       "145  b43a7600  \n",
       "34   3e131610  \n",
       "52   3b8eed30  \n",
       "33   639b18a0  "
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# A slightly more involved example of obtaining information\n",
    "# on the fluids in REFPROP, and storing it in a pandas \n",
    "# DataFrame for further sorting, grouping, etc.\n",
    "\n",
    "# The search pattern for finding pure fluid files\n",
    "FLUIDSglob = os.path.join(os.environ['RPPREFIX'],\n",
    "                          'FLUIDS','*.FLD')\n",
    "data = []\n",
    "# Loop over the fluid files found\n",
    "for fname in glob.glob(FLUIDSglob):\n",
    "    # The fluid name is obtained as the string\n",
    "    # to the right of the last path delimiter\n",
    "    # and before the period.\n",
    "    fld = os.path.split(fname)[1].split('.')[0]\n",
    "    \n",
    "    # Make a dictionary to collect information about\n",
    "    # the fluid\n",
    "    info = {'NAME':fld}\n",
    "    # Numerical values w/ units\n",
    "    for k in ['TC', 'PC', 'DC']:\n",
    "        r = RP.REFPROPdll(fld,\" \",k,MOLAR_SI,0,0,0,0,z)\n",
    "        heading = k + ' [' + r.hUnits + ']'\n",
    "        info[heading] = r.Output[0]\n",
    "        \n",
    "    # String things\n",
    "    for k in ['INCHIKEY','HASH']:\n",
    "        r = RP.REFPROPdll(fld,\" \",k,MOLAR_SI,0,0,0,0,z)\n",
    "        info[k] = r.hUnits\n",
    "        \n",
    "    # Store the dictionary in the list\n",
    "    data.append(info)\n",
    "\n",
    "# The complete DataFrame for all fluids; flatten the \n",
    "# list of dictionaries into a DataFrame\n",
    "df = pandas.DataFrame(data)\n",
    "\n",
    "# Print the first lines of the DataFrame as sorted by\n",
    "# critical density in decreasing order\n",
    "df.sort_values(by='DC [mol/dm^3]',ascending=False).head(5)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Flash Calculations\n",
    "\n",
    "One of the primary uses of REFPROP is to be able to calculate properties as a function of state variables other than temperature and density (the natural variables of the equation of state).  Therefore you need to be able to input other properties, and obtain the temperature and density, from which you can obtain all other thermodynamic properties explicitly.  \n",
    "\n",
    "The following thermodynamic variables are allowed as inputs for the thermodynamic state: ``T``,``P``,``D``,``H``,``S``,``E``.  Two of them are required to fix the state.  In this example we calculate the density and vapor quality (on a molar basis) for the mixture of decane + nitrogen."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(0.06773707807258046, 0.6006648171487302)"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "units = RP.GETENUMdll(0,'DEFAULT').iEnum\n",
    "o = RP.REFPROPdll(\"Decane * Nitrogen\",\"TP\",\"D;Qmole\",units,0,0,298,101.325,[0.4, 0.6])\n",
    "assert(o.ierr == 0)\n",
    "D_molL, Qmole = o.Output[0:2]\n",
    "D_molL, Qmole"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Phase Boundary for Mixtures"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now let's do something fun (and instructive) --  plot the isopleth (line of constant composition of the phase envelope) for this composition and show where our STP (standard temperature and pressure) state point is."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYoAAAELCAYAAADHksFtAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNp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wvR4S1m1i/6fD8iv4VD5DeTgTFvHwBUtlWtrSF6yP5nYBLZuZ/nAJPNbAMwC7jQzH5NFu6ru1dG/7kV+B8ip1eybj+J1F4ePQoGeJ5IcGTjvioo0o2ZGZHznqvd/ScxT80Fvhp9/FVgTsz4VDNrb2aDgWHA+21V79Eys15mVhx9XARcDHxElu0ngLvf5e4D3H0QMBV4w92vJcv21cw6mVmXhsfAF4AVZNl+Arj7ZmCjmY2IDl0ErCIL9xV0z+x0dA5wHbA8ev4e4HvAfcBsM7sR+Az4CoC7rzSz2UT+koaAW9y9vs2rPnL9gF+aWT6RX1hmu/tLZvYu2bWfyWTbf9M+wP9EftehHfAbd/+jmS0ku/azwTeBZ82sEFgPfI3o3+Vs21etzBYRkaR06klERJJSUIiISFIKChERSUpBISIiSSkoREQkKQWFiIgkpaAQOQZm1iPaUnuJmW02s4qY7cKY19VHx/pHtzeYWc/o43Fm9omZjTGzq6KtqF8Kap9EGtOCO5Fj4O47gNEAZnYvsM/dfxznpdXRvlaHMbPTiLR/uMrdFwOLzWwLcEeqahY5UjqiEAnOScCLwHXunjHtHCT36IhCJDhzgGvd/a2gCxFJRkcUIsF5Dbgp2u9KJG0pKESCc2v0nz8LtAqRZigoRIITBq4GRpjZD4IuRiQRBYVIgNy9lsj9lCeb2S1B1yMSjy5mi7QSd7/3CF47KObxbqJTbEXSkY4oRNrGntgFd4mY2VVErlnsapuyRJqnGxeJiEhSOqIQEZGkFBQiIpKUgkJERJJSUIiISFIKChERSer/A2aOCjP6lmKfAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Obtain the isopleth data\n",
    "# ---\n",
    "# Set up the fluids we want\n",
    "RP.SETFLUIDSdll('Decane * Nitrogen')\n",
    "# Construct the saturation spline\n",
    "RP.SATSPLNdll([0.4,0.6])\n",
    "# Now we programatically extract the nodes of the isopleth...\n",
    "Nnodes = RP.REFPROPdll(\"\",\"SPLINENODES\",\"\",0,0,0,0,0,[0.4,0.6]).iUCode\n",
    "data = []\n",
    "for i in range(1,Nnodes+1):\n",
    "    rho_vap,T,p,rho_eq,z0,z1 = RP.REFPROPdll(\"\",\"SPLINENODES\",\"\",0,0,i,0,0,[0.4,0.6]).Output[0:6]\n",
    "    data.append(dict(rho_vap = rho_vap,T=T,p=p,z0=z0,z1=z1))\n",
    "# Convert the data points into a pandas DataFrame\n",
    "df = pandas.DataFrame(data)\n",
    "# And plot them...\n",
    "plt.plot(df['T'],df.p,'o-')\n",
    "\n",
    "# Plot the specified state point at STP\n",
    "plt.plot(298, 101.325,'o-',ms=8)\n",
    "\n",
    "plt.yscale('log')\n",
    "plt.xlabel('T [K]')\n",
    "plt.ylabel('p [kPa]')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "And now let's reproduce the same output with the legacy ``SPLNVALdll`` function.  Docs:\n",
    "```\n",
    "subroutine SPLNVAL (isp,iderv,a,f,ierr,herr)\n",
    "c\n",
    "c  calculates the function value of a spline\n",
    "c\n",
    "c  inputs:\n",
    "c      isp--indicator for which spline to use (1-nc: composition,\n",
    "c           nc+1: temperature, nc+2: pressure, nc+3: density,\n",
    "c           nc+4: enthalpy, nc+5: entropy)\n",
    "c    iderv--values of -1 and -2 return lower and upper root values,\n",
    "c           value of 0 returns spline function, value of 1 returns\n",
    "c           derivative of spline function with respect to density\n",
    "c        a--root value\n",
    "c  outputs:\n",
    "c        f--value of spline function at input root\n",
    "c     ierr--error flag:   0 = successful\n",
    "c     herr--error string (character*255)\n",
    "``` "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYoAAAELCAYAAADHksFtAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6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EhECgqRT8HM+oSX1F5hZrvMbHuL/dQWxwXCbYPC+5vNrG94e5KZfWRmE8zs8vBS1M97dU4iremGO5FPwTlXAZwAYGa3A1XOuV+3cWhteF2rQ5jZOELLP1zunFsOLDez3cAPolWzyJFSj0LEO6OBZ4ErnXPdZjkHSTzqUYh45zngCufcW14XIhKJehQi3nkVuCa83pVIzFJQiHjnhvDX//W0CpHDUFCIeCcITAeKzOy/vS5GpD0KChEPOefqCT1P+Utm9m2v6xFpiy5mi3QS59ztR3BsYYvtA4Sn2IrEIvUoRLrGwZY33LXHzC4ndM1iX9eUJXJ4enCRiIhEpB6FiIhEpKAQEZGIFBQiIhKRgkJERCJSUIiISET/H8oMBZlLyDpGAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Reset...\n",
    "RP.SETFLUIDSdll('ARGON')\n",
    "# Set up the fluids we want\n",
    "RP.SETFLUIDSdll('Decane*Nitrogen')\n",
    "# Construct the saturation spline\n",
    "RP.SATSPLNdll([0.4,0.6])\n",
    "\n",
    "# Now we programatically extract smoothed values\n",
    "nc = 2 # two components\n",
    "\n",
    "# These limits are the densities of the \"vapor\" phase\n",
    "rhomolarmin = RP.SPLNVALdll(nc+1, -1, 0).f\n",
    "rhomolarmax = RP.SPLNVALdll(nc+1, -2, 0).f\n",
    "\n",
    "Nnodes = RP.REFPROPdll(\"\",\"SPLINENODES\",\"\",0,0,0,0,0,[0.4,0.6]).iUCode\n",
    "iT = nc+1\n",
    "iP = nc+2\n",
    "iD = nc+3\n",
    "iH = nc+4\n",
    "iS = nc+5\n",
    "\n",
    "data = []\n",
    "for rho in np.geomspace(rhomolarmin, rhomolarmax, 10000):\n",
    "    # rho_eq is the density of the \"other\" phase\n",
    "    T,p,rho_eq,h,s = [RP.SPLNVALdll(k, 0, rho).f for k in [iT, iP, iD, iH, iS]]\n",
    "    data.append(dict(rho_vap=rho_eq, T=T, p=p))\n",
    "    \n",
    "# Convert the data points into a pandas DataFrame\n",
    "df = pandas.DataFrame(data)\n",
    "# And plot them...\n",
    "plt.plot(df['T'],df.p,'-')\n",
    "\n",
    "# Plot the specified state point at STP\n",
    "plt.plot(298, 101.325,'o-',ms=8)\n",
    "\n",
    "plt.yscale('log')\n",
    "plt.xlabel('T [K]')\n",
    "plt.ylabel('p [kPa]')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This is a non-Type I mixture, therefore the \"bubble\" side of the phase enevelope continues up to high pressures.  This is common behavior for mixtures formed of asymmetric components."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Speed!"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Set up REFPROP with Water as the fluid\n",
    "RP.SETFLUIDSdll(\"Water\");"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "70.6 µs ± 845 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)\n"
     ]
    }
   ],
   "source": [
    "# The convenient REFPROP function introduces a significant amount of overhead\n",
    "%timeit RP.REFPROPdll(\"\",\"PQ\",\"T\",RP.MOLAR_BASE_SI,0,0,1e5,0,[1.0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "9.81 µs ± 166 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)\n"
     ]
    }
   ],
   "source": [
    "# This is much faster because the overhead of the REFPROPdll function is avoided\n",
    "%timeit RP.ABFLSHdll('PQ', 101.325, 0, [1.0], 0)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Reference States"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "array('d', [199999.99999999994, 1000.0]) :::::: (should be 200000, 1000)\n",
      "array('d', [-1.4502312524103079e-11, 0.0]) :::::: (should be ~0, ~0)\n",
      "array('d', [99643.47646668972, 392.9541869991858]) :::::: (should be 200000, 1000)\n"
     ]
    }
   ],
   "source": [
    "MASS_BASE_SI = RP.GETENUMdll(0, \"MASS BASE SI\").iEnum\n",
    "RP.SETFLUIDSdll(\"PROPANE\");\n",
    "z = [1.0]+[0.0]*19\n",
    "\n",
    "# Do a saturation call at one 273.15 K, check H and S are equal to the \n",
    "# default reference state (IIR, h = 200 kJ/kg, s = 1 kJ/kg-K for sat. liquid at 0 C)\n",
    "r = RP.REFPROPdll(\"PROPANE\", \"QT\", \"H;S\", MASS_BASE_SI, 0, 0, 0, 273.15, z)\n",
    "print(r.Output[0:2], \":::::: (should be 200000, 1000)\")\n",
    "\n",
    "# Now we set the reference state to something else, in this case NBP\n",
    "# with h,s = 0 at normal boiling point (saturated liquid at 1 atmosphere (101325 Pa))\n",
    "icomp = 1\n",
    "RP.SETREFdll(\"NBP\", icomp, z, -1,-1,-1,-1) # -1 are placeholders, not needed, but must be passed\n",
    "\n",
    "# Confirm that we get the right enthalpy and entropy at the reference state\n",
    "# They should be 0 and 0 for H and S\n",
    "r = RP.REFPROPdll(\"PROPANE\", \"PQ\", \"H;S\", MASS_BASE_SI, 0,0, 101325, 0, z)\n",
    "print(r.Output[0:2], \":::::: (should be ~0, ~0)\")\n",
    "\n",
    "# Unset the reference state for propane by selecting a new fluid\n",
    "RP.SETFLUIDSdll(\"DECANE\");\n",
    "\n",
    "# This should be back to IIR again\n",
    "r = RP.REFPROPdll(\"PROPANE\", \"QT\", \"H;S\", MASS_BASE_SI, 0, 0, 0, 273.15, z)\n",
    "print(r.Output[0:2], \":::::: (should be 200000, 1000)\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Setting Up Predefined Mixture"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "SETMIXdlloutput(ncc=3, hFiles='R32.FLD|R125.FLD|R134A.FLD|', z=array('d', [0.473194694453358, 0.205109095413331, 0.321696210133311, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]), ierr=0, herr='')\n",
      "SETREFdlloutput(ierr=0, herr='')\n",
      "200000.0 1000.0\n"
     ]
    }
   ],
   "source": [
    "mix = 'R407F.mix'\n",
    "sm = RP.SETMIXdll(mix,'HMX.BNC','IIR')\n",
    "print(sm)\n",
    "print(RP.SETREFdll('IIR',2,sm.z,0,0,0,0))\n",
    "r = RP.REFPROPdll(\"\", \"QT\", \"H;S;M\", RP.MOLAR_BASE_SI,0,0,0,273.15,sm.z)\n",
    "Hmolar, Smolar, M = r.Output[0:3]\n",
    "print(Hmolar/M, Smolar/M)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python [conda env:py38] *",
   "language": "python",
   "name": "conda-env-py38-py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
